*/
#undef DEBUG
-#undef DEBUG_FAIL
+#undef DEBUG_LOW
#include <xen/config.h>
#include <xen/types.h>
#include <asm/papr.h>
#include <asm/hcalls.h>
+#ifdef DEBUG
+#define DBG(fmt...) printk(fmt)
+#else
+#define DBG(fmt...)
+#endif
+#ifdef DEBUG_LOW
+#define DBG_LOW(fmt...) printk(fmt)
+#else
+#define DBG_LOW(fmt...)
+#endif
+
#ifdef USE_PTE_INSERT
static inline void pte_insert(union pte volatile *pte,
ulong vsid, ulong rpn, ulong lrpn)
htab = &d->arch.htab;
if (ptex > (1UL << htab->log_num_ptes)) {
+ DBG("%s: bad ptex: 0x%lx\n", __func__, ptex);
regs->gprs[3] = H_Parameter;
- printk("%s: bad ptex: 0x%lx\n", __func__, ptex);
return;
}
}
if ( lp_size >= d->arch.large_page_sizes ) {
- printk("%s: attempt to use unsupported lp_size %d\n",
- __func__, lp_size);
+ DBG("%s: attempt to use unsupported lp_size %d\n",
+ __func__, lp_size);
regs->gprs[3] = H_Parameter;
return;
}
mfn = pfn2mfn(d, pfn, &mtype);
if (mfn == INVALID_MFN) {
+ DBG("%s: Bad PFN: 0x%lx\n", __func__, pfn);
regs->gprs[3] = H_Parameter;
return;
}
if (mtype == PFN_TYPE_IO) {
/* only a privilaged dom can access outside IO space */
if ( !d->is_privileged ) {
+ DBG("%s: unprivileged access to physical page: 0x%lx\n",
+ __func__, pfn);
regs->gprs[3] = H_Privilege;
- printk("%s: unprivileged access to physical page: 0x%lx\n",
- __func__, pfn);
return;
}
if ( !((pte.bits.w == 0)
&& (pte.bits.i == 1)
&& (pte.bits.g == 1)) ) {
-#ifdef DEBUG_FAIL
- printk("%s: expecting an IO WIMG "
- "w=%x i=%d m=%d, g=%d\n word 0x%lx\n", __func__,
- pte.bits.w, pte.bits.i, pte.bits.m, pte.bits.g,
- pte.words.rpn);
-#endif
+ DBG("%s: expecting an IO WIMG "
+ "w=%x i=%d m=%d, g=%d\n word 0x%lx\n", __func__,
+ pte.bits.w, pte.bits.i, pte.bits.m, pte.bits.g,
+ pte.words.rpn);
regs->gprs[3] = H_Parameter;
return;
}
BUG_ON(f == d);
if (unlikely(!get_domain(f))) {
+ DBG("%s: Rescinded, no domain: 0x%lx\n", __func__, pfn);
regs->gprs[3] = H_Rescinded;
return;
}
if (unlikely(!get_page(pg, f))) {
put_domain(f);
+ DBG("%s: Rescinded, no page: 0x%lx\n", __func__, pfn);
regs->gprs[3] = H_Rescinded;
return;
}
}
}
-#ifdef DEBUG
/* If the PTEG is full then no additional values are returned. */
- printk("%s: PTEG FULL\n", __func__);
-#endif
+ DBG("%s: PTEG FULL\n", __func__);
if (pg != NULL)
put_page(pg);
union pte volatile *ppte;
union pte lpte;
-#ifdef DEBUG
- printk("%s: flags: 0x%lx ptex: 0x%lx avpn: 0x%lx\n", __func__,
- flags, ptex, avpn);
-#endif
+ DBG_LOW("%s: flags: 0x%lx ptex: 0x%lx avpn: 0x%lx\n", __func__,
+ flags, ptex, avpn);
if ( ptex > (1UL << htab->log_num_ptes) ) {
+ DBG("%s: bad ptex: 0x%lx\n", __func__, ptex);
regs->gprs[3] = H_Parameter;
- printk("%s: bad ptex: 0x%lx\n", __func__, ptex);
return;
}
ppte = &htab->map[ptex];
/* the AVPN param occupies the bit-space of the word */
if ( (flags & H_AVPN) && lpte.bits.avpn != avpn >> 7 ) {
-#ifdef DEBUG_FAIL
- printk("%s: %p: AVPN check failed: 0x%lx, 0x%lx\n", __func__,
- ppte, lpte.words.vsid, lpte.words.rpn);
-#endif
+ DBG("%s: %p: AVPN check failed: 0x%lx, 0x%lx\n", __func__,
+ ppte, lpte.words.vsid, lpte.words.rpn);
regs->gprs[3] = H_Not_Found;
return;
}
* we invalidate entires where the PAPR says to 0 the whole hi
* dword, so the AVPN should catch this first */
-#ifdef DEBUG_FAIL
- printk("%s: pte invalid\n", __func__);
-#endif
+ DBG("%s: pte invalid\n", __func__);
regs->gprs[3] = H_Not_Found;
return;
}
union pte volatile *pte;
union pte lpte;
-#ifdef DEBUG
- printk("%s: flags: 0x%lx ptex: 0x%lx\n", __func__,
- flags, ptex);
-#endif
+ DBG_LOW("%s: flags: 0x%lx ptex: 0x%lx\n", __func__,
+ flags, ptex);
+#ifdef DEBUG
if (flags != 0) {
- printk("WARNING: %s: "
- "flags are undefined and should be 0: 0x%lx\n",
- __func__, flags);
+ DBG("WARNING: %s: "
+ "flags are undefined and should be 0: 0x%lx\n",
+ __func__, flags);
}
+#endif
if (ptex > (1UL << htab->log_num_ptes)) {
+ DBG("%s: bad ptex: 0x%lx\n", __func__, ptex);
regs->gprs[3] = H_Parameter;
- printk("%s: bad ptex: 0x%lx\n", __func__, ptex);
return;
}
pte = &htab->map[ptex];
union pte volatile *pte;
union pte lpte;
-#ifdef DEBUG
- printk("%s: flags: 0x%lx ptex: 0x%lx\n", __func__,
+ DBG_LOW("%s: flags: 0x%lx ptex: 0x%lx\n", __func__,
flags, ptex);
-#endif
+
+#ifdef DEBUG
if (flags != 0) {
- printk("WARNING: %s: "
- "flags are undefined and should be 0: 0x%lx\n",
- __func__, flags);
+ DBG("WARNING: %s: "
+ "flags are undefined and should be 0: 0x%lx\n",
+ __func__, flags);
}
-
+#endif
+
if (ptex > (1UL << htab->log_num_ptes)) {
+ DBG("%s: bad ptex: 0x%lx\n", __func__, ptex);
regs->gprs[3] = H_Parameter;
- printk("%s: bad ptex: 0x%lx\n", __func__, ptex);
return;
}
pte = &htab->map[ptex];
union pte volatile *pte;
union pte lpte;
-#ifdef DEBUG
- printk("%s: flags: 0x%lx ptex: 0x%lx avpn: 0x%lx\n", __func__,
- flags, ptex, avpn);
-#endif
+ DBG_LOW("%s: flags: 0x%lx ptex: 0x%lx avpn: 0x%lx\n", __func__,
+ flags, ptex, avpn);
+
if ( ptex > (1UL << htab->log_num_ptes) ) {
+ DBG("%s: bad ptex: 0x%lx\n", __func__, ptex);
regs->gprs[3] = H_Parameter;
- printk("%s: bad ptex: 0x%lx\n", __func__, ptex);
return;
}
pte = &htab->map[ptex];
lpte.words.rpn = pte->words.rpn;
if ((flags & H_AVPN) && lpte.bits.avpn != (avpn >> 7)) {
-#ifdef DEBUG_FAIL
- printk("%s: avpn doesn not match\n", __func__);
-#endif
+ DBG("%s: avpn doesn not match\n", __func__);
regs->gprs[3] = H_Not_Found;
return;
}
if ((flags & H_ANDCOND) && ((avpn & pte->words.vsid) != 0)) {
-#ifdef DEBUG_FAIL
- printk("%s: andcond does not match\n", __func__);
-#endif
+ DBG("%s: andcond does not match\n", __func__);
regs->gprs[3] = H_Not_Found;
return;
}
regs->gprs[4] = lpte.words.vsid;
regs->gprs[5] = lpte.words.rpn;
+#ifdef DEBUG_LOW
/* XXX - I'm very skeptical of doing ANYTHING if not bits.v */
/* XXX - I think the spec should be questioned in this case (MFM) */
if (lpte.bits.v == 0) {
- printk("%s: removing invalid entry\n", __func__);
+ DBG_LOW("%s: removing invalid entry\n", __func__);
}
+#endif
if (lpte.bits.v) {
ulong mfn = lpte.bits.rpn;
ptex &= ~0x3UL;
if (ptex > (1UL << htab->log_num_ptes)) {
+ DBG("%s: bad ptex: 0x%lx\n", __func__, ptex);
regs->gprs[3] = H_Parameter;
- printk("%s: bad ptex: 0x%lx\n", __func__, ptex);
return;
}
pte = &htab->map[ptex];